﻿Imports System.Linq
Imports TNCDAL

Public Class DemDetController
    Private objRepository As New DemDetRepository

    Public Function SelectAllRecord() As IQueryable(Of tblDemDet)
        Return objRepository.SelectAllRecord()
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblDemDet
        Return objRepository.SelectRecordById(id)
    End Function

    Public Sub Insert(ByVal obj As tblDemDet)
        objRepository.Insert(obj)
    End Sub

    Public Sub Update(ByVal obj As tblDemDet)
        objRepository.Update(obj)
    End Sub

    Public Function SelectCustom(ByVal strName As String) As IQueryable
        Dim query = SelectAllRecord()

        If strName <> "" Then
            query = query.Where(Function(p) p.DemDetName.ToLower.Contains(strName.ToLower))
        End If

        query = query.OrderBy(Function(p) p.DemDetName)
        Return query
    End Function
End Class
